package com.wnxy.sddfp.common.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class TokenUtils {
    public static String getTokenUserId() {
        // RequestContextHolder  容器、负责人
        // 可以通过负责人 获取请求对象 HttpServletRequest
        HttpServletRequest request= ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String userId = request.getHeader("userId");
        return userId.toString();
    }
}